Svelte provides three ways to animate elements entering or leaving the DOM: transition, in, and out. While they are related, each serves a specific purpose.
transition: is a shorthand for applying both entry and exit transitions to an element. When you use transition:fade, the element will animate both when it is added to the DOM and when it is removed.
in: applies a transition only when the element enters the DOM. It does not animate the element when it leaves. Use this when you want to animate only the entrance of an element.
out: applies a transition only when the element leaves the DOM. It does not animate the element when it enters. Use this when you want to animate only the exit of an element.
transition: – applies both enter (in) and leave (out) transitions.
in: – applies a transition only when the element enters the DOM.
out: – applies a transition only when the element leaves the DOM.
Use in or out individually if you want different transitions for entry and exit.
All three directives support options like duration, delay, and easing.